package com.fastloan.mgt.chatapp.controller;

import com.fastloan.mgt.chatapp.service.ParamService;
import com.fastloan.utils.WeixinUtil;
import com.kawins.result.ResultTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author rankai
 *         createTime 2017-12-2017/12/27 13:04
 */
@RestController
@RequestMapping("/api/param/anon")
public class ParamController {

    @Autowired
    private ParamService paramService;

    @PostMapping("/signature")
    public ResultTo signature(@RequestParam("appId") String appId, @RequestParam("secret") String secret) {
        return new ResultTo().setData(WeixinUtil.getAccessToken(appId, secret));
    }

    @PostMapping("/chatJsapi")
    public ResultTo chatJsapi(@RequestParam("appId") String appId, @RequestParam("secret") String secret) {
        return new ResultTo().setData(WeixinUtil.getJsapi(appId, secret));
    }

}
